/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package View;

import Componenten.LocalTypes;
import Componenten.SQLiteConnector;
import Model.Bord;
import Model.Level;
import java.awt.Color;
import java.awt.HeadlessException;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JOptionPane;
import javax.swing.Timer;

/**
 *
 * @author Bram Slob en Roderick van Seijen
 */
public class Sokoban extends javax.swing.JFrame implements ActionListener, LocalTypes {
    private BordView bordView;
    private Timer timer;
    private Bord bord;
    
    /**
     * Creates new form Sokoban
     */
    public Sokoban() {
        initComponents();
        bordView = (BordView) bordPanel;
        bord = bordView.getBord();
        bordView.requestFocus();
        volgendeLevelKnop.setVisible(false);
        herstartLevelKnop.setVisible(false);
        CreditsLabel.setVisible(false);
        verwijderHighscoreKnop.setVisible(false);
        timer = new Timer(1000, this);
        showMenuLabels(false);
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        buttonGroup5 = new javax.swing.ButtonGroup();
        menuPanel = new javax.swing.JPanel();
        startSpelKnop = new javax.swing.JButton();
        herstartLevelKnop = new javax.swing.JButton();
        stappenLabel = new javax.swing.JLabel();
        stappenTeller = new javax.swing.JLabel();
        scoreLabel = new javax.swing.JLabel();
        scoreTeller = new javax.swing.JLabel();
        volgendeLevelKnop = new javax.swing.JButton();
        kindmodusKnop = new javax.swing.JToggleButton();
        highscoreLabel = new javax.swing.JLabel();
        highscoreTeller = new javax.swing.JLabel();
        verwijderHighscoreKnop = new javax.swing.JButton();
        uitgebreideVariantKnop = new javax.swing.JToggleButton();
        levelLabel = new javax.swing.JLabel();
        levelTeller = new javax.swing.JLabel();
        kiesLevelKnop = new javax.swing.JButton();
        bordPanel = new BordView(this);
        CreditsLabel = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Sokoban");
        setResizable(false);

        menuPanel.setPreferredSize(new java.awt.Dimension(175, 396));
        menuPanel.setRequestFocusEnabled(false);

        startSpelKnop.setText("Start spel");
        startSpelKnop.setToolTipText("(Her)start het spel vanaf level 1.");
        startSpelKnop.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                startSpelKnopActionPerformed(evt);
            }
        });

        herstartLevelKnop.setText("Herstart level");
        herstartLevelKnop.setToolTipText("Herstart de huidige level.");
        herstartLevelKnop.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                herstartLevelKnopActionPerformed(evt);
            }
        });

        stappenLabel.setText("Stappen:");

        stappenTeller.setMaximumSize(new java.awt.Dimension(40, 14));
        stappenTeller.setMinimumSize(new java.awt.Dimension(40, 14));

        scoreLabel.setText("Bezette eindvakken:");

        volgendeLevelKnop.setText("Volgende level");
        volgendeLevelKnop.setToolTipText("Ga naar de volgende level.");
        volgendeLevelKnop.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                volgendeLevelKnopActionPerformed(evt);
            }
        });

        kindmodusKnop.setText("Kindmodus");
        kindmodusKnop.setToolTipText("Bij de Kindmodus kunnen meerdere dozen tegelijk geduwd worden.");
        kindmodusKnop.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                kindmodusKnopActionPerformed(evt);
            }
        });

        highscoreLabel.setText("Highscore:");

        highscoreTeller.setMaximumSize(new java.awt.Dimension(40, 14));
        highscoreTeller.setMinimumSize(new java.awt.Dimension(40, 14));

        verwijderHighscoreKnop.setText("Verwijder highscore");
        verwijderHighscoreKnop.setToolTipText("Verwijder de highscore voor de huidige combinatie van level, modus en spelvariant.");
        verwijderHighscoreKnop.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                verwijderHighscoreKnopActionPerformed(evt);
            }
        });

        uitgebreideVariantKnop.setText("Uitgebreide variant");
        uitgebreideVariantKnop.setToolTipText("Bij de uitgebreide spelvariant moeten dozen eerst gevuld worden met ballen.");
        uitgebreideVariantKnop.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                uitgebreideVariantKnopActionPerformed(evt);
            }
        });

        levelLabel.setText("Level:");

        kiesLevelKnop.setText("Kies level");
        kiesLevelKnop.setToolTipText("Kies een level.");
        kiesLevelKnop.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                kiesLevelKnopActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout menuPanelLayout = new javax.swing.GroupLayout(menuPanel);
        menuPanel.setLayout(menuPanelLayout);
        menuPanelLayout.setHorizontalGroup(
            menuPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(menuPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(menuPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(menuPanelLayout.createSequentialGroup()
                        .addComponent(highscoreLabel)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(highscoreTeller, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(menuPanelLayout.createSequentialGroup()
                        .addComponent(stappenLabel)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(stappenTeller, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(menuPanelLayout.createSequentialGroup()
                        .addComponent(scoreLabel)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(scoreTeller, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addComponent(uitgebreideVariantKnop, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(volgendeLevelKnop, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(verwijderHighscoreKnop, javax.swing.GroupLayout.DEFAULT_SIZE, 155, Short.MAX_VALUE)
                    .addComponent(kindmodusKnop, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, menuPanelLayout.createSequentialGroup()
                        .addComponent(levelLabel)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(levelTeller, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addComponent(herstartLevelKnop, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(startSpelKnop, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(kiesLevelKnop, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        menuPanelLayout.setVerticalGroup(
            menuPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(menuPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(menuPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(highscoreLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(highscoreTeller, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(menuPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(stappenLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(stappenTeller, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(menuPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(scoreLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(scoreTeller, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(menuPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(levelLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(levelTeller, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addGap(18, 18, 18)
                .addComponent(startSpelKnop)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(herstartLevelKnop)
                .addGap(8, 8, 8)
                .addComponent(kiesLevelKnop)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(kindmodusKnop)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(uitgebreideVariantKnop)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(volgendeLevelKnop)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 46, Short.MAX_VALUE)
                .addComponent(verwijderHighscoreKnop)
                .addContainerGap())
        );

        getContentPane().add(menuPanel, java.awt.BorderLayout.LINE_START);

        bordPanel.setPreferredSize(new java.awt.Dimension(720, 396));

        CreditsLabel.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        CreditsLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        CreditsLabel.setText("<html> <div align=\"center\"><p style=\"font-size: 18pt;\">Credits</p><br> <p style =\"font-size: 11pt;\">Design & programmeren:<br><br> Bram Slob<br> Roderick van Seijen<br> </p></div>");

        jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel2.setText("© 2013 ForFun BV");

        jLabel3.setFont(new java.awt.Font("Tahoma", 0, 36)); // NOI18N
        jLabel3.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel3.setText("Sokoban");

        javax.swing.GroupLayout bordPanelLayout = new javax.swing.GroupLayout(bordPanel);
        bordPanel.setLayout(bordPanelLayout);
        bordPanelLayout.setHorizontalGroup(
            bordPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(bordPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(bordPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(CreditsLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 867, Short.MAX_VALUE))
                .addContainerGap())
            .addGroup(bordPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(bordPanelLayout.createSequentialGroup()
                    .addContainerGap()
                    .addComponent(jLabel3, javax.swing.GroupLayout.DEFAULT_SIZE, 867, Short.MAX_VALUE)
                    .addContainerGap()))
        );
        bordPanelLayout.setVerticalGroup(
            bordPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(bordPanelLayout.createSequentialGroup()
                .addGap(131, 131, 131)
                .addComponent(jLabel2)
                .addGap(49, 49, 49)
                .addComponent(CreditsLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(79, Short.MAX_VALUE))
            .addGroup(bordPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(bordPanelLayout.createSequentialGroup()
                    .addGap(80, 80, 80)
                    .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(238, Short.MAX_VALUE)))
        );

        getContentPane().add(bordPanel, java.awt.BorderLayout.CENTER);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void startSpelKnopActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_startSpelKnopActionPerformed
        bord.startSpel();
        updateMenu();
    }//GEN-LAST:event_startSpelKnopActionPerformed

    private void herstartLevelKnopActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_herstartLevelKnopActionPerformed
        bord.herstartLevel();
        updateMenu();
    }//GEN-LAST:event_herstartLevelKnopActionPerformed

    private void volgendeLevelKnopActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_volgendeLevelKnopActionPerformed
        bord.startVolgendeLevel();
        updateMenu();
    }//GEN-LAST:event_volgendeLevelKnopActionPerformed

    private void verwijderHighscoreKnopActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_verwijderHighscoreKnopActionPerformed
        Level.verwijderHighscore(bord.getLevelCode(), bord.getSpeelModus(), bord.getSpelVariant());
        updateHighscore();
        bordView.requestFocus();
    }//GEN-LAST:event_verwijderHighscoreKnopActionPerformed

    private void kiesLevelKnopActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_kiesLevelKnopActionPerformed
        int levels = Level.getAantalLevels();
        String input = JOptionPane.showInputDialog(this, "Kies de gewenste level (1 t/m " + levels + "):");
        if (input != null){
            if (input.equals("")){
                JOptionPane.showMessageDialog(this, "Geen levelnummer ingevuld.");
            } else {
                try {
                    int lvl = Integer.parseInt(input);
                    if (lvl >= 1 && lvl <= levels){
                        bord.startLevel(lvl);
                        herstartLevelKnop.setVisible(true);
                        updateMenu();
                    } else {
                        JOptionPane.showMessageDialog(this, "Ongeldig levelnummer ingevuld.");
                    }
                } catch (NumberFormatException | HeadlessException e){
                    JOptionPane.showMessageDialog(this, "Ongeldig levelnummer ingevuld.");
                }
            }
        }
        bordView.requestFocus();
    }//GEN-LAST:event_kiesLevelKnopActionPerformed

    private void uitgebreideVariantKnopActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_uitgebreideVariantKnopActionPerformed
        boolean doorgaan = true;
        if (bord.getLevelCode() > 0 && !bord.isLevelGehaald() && bord.getStappen() > 0){
            int antwoord = JOptionPane.showConfirmDialog(this, "Hiervoor dient de level herstart te worden. Doorgaan?", "Spelvariant wijzigen", JOptionPane.YES_NO_OPTION);
            if (antwoord != JOptionPane.YES_OPTION) doorgaan = false;
        }
        if (doorgaan){
            if(bord.getSpelVariant() == SpelVariant.STANDAARD){
                bord.setSpelVariant(SpelVariant.UITGEBREID);
            } else {
                bord.setSpelVariant(SpelVariant.STANDAARD);
            }
            if (bord.getLevelCode() > 0 && !bord.isLevelGehaald()){
                bord.herstartLevel();
                updateMenu();
            }
        } else {
            if (bord.getSpelVariant() == SpelVariant.STANDAARD) {
                uitgebreideVariantKnop.setSelected(false);
            } else {
                uitgebreideVariantKnop.setSelected(true);
            }
        }
        updateHighscore();
        bordView.requestFocus();
    }//GEN-LAST:event_uitgebreideVariantKnopActionPerformed

    private void kindmodusKnopActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_kindmodusKnopActionPerformed
        boolean doorgaan = true;
        if(bord.getSpeelModus() == Modus.VOLWASSENE){
            bord.setSpeelModus(Modus.KIND);
        } else {
            if (bord.getLevelCode() > 0 && !bord.isLevelGehaald() && bord.getStappen() > 0){
                int antwoord = JOptionPane.showConfirmDialog(this, "Hiervoor dient de level herstart te worden. Doorgaan?", "Kindmodus verlaten", JOptionPane.YES_NO_OPTION);
                if (antwoord != JOptionPane.YES_OPTION) doorgaan = false;
            }
            if (doorgaan){
                bord.setSpeelModus(Modus.VOLWASSENE);
                if (bord.getLevelCode() > 0 && !bord.isLevelGehaald()){
                    bord.herstartLevel();
                    updateMenu();
                }
            } else {
                kindmodusKnop.setSelected(true);
            }
        }
        updateHighscore();
        bordView.requestFocus();
    }//GEN-LAST:event_kindmodusKnopActionPerformed
    
    /**
     * Maakt de labels voor de variabelen bovenin het menu (on)zichtbaar.
     * @param visible   Boolean waarde (zichtbaar / onzichtbaar)
     */
    private void showMenuLabels(boolean visible){
        highscoreLabel.setVisible(visible);
        scoreLabel.setVisible(visible);
        stappenLabel.setVisible(visible);
        levelLabel.setVisible(visible);
    }
    
    /**
     * Update alle relevante tekstvelden, labels en knoppen in het menu. Voor gebruik bij (her)start level.
     */
    private void updateMenu(){
        if (timer.isRunning()) timer.stop();
        volgendeLevelKnop.setVisible(false);
        bordView.updateScherm();
        herstartLevelKnop.setVisible(true);
        startSpelKnop.setText("Herstart spel");
        showMenuLabels(true);
        updateHighscore();
        updateBezetteEindvakken();
        updateStappen();
        updateLevelTeller();
        bordView.requestFocus();
    }
    
    /**
     * Update het aantal stappen van de gebruiker. 
     * De gegevens hiervoor komen uit Bord.
     */
    public void updateStappen(){
        this.stappenTeller.setText(bord.getStappen() + "");
    }
    
    /**
     * Voeg de credits toe aan het beginscherm. 
     */
    public void showCredits(){
        CreditsLabel.setVisible(true);
    }
    
    /**
     * Update de weergave van de huidige level en het totaal aantal levels. 
     * De gegevens hiervoor komen uit Bord en Level.
     */
    public void updateLevelTeller(){
        this.levelTeller.setText(bord.getLevelCode() + " / " + Level.getAantalLevels());
    }
    
    /**
     * Update de highscore voor de huidige level. Zet de highscore op 0 als er geen level gekozen is.
     */
    public void updateHighscore(){
        int score = Level.getHighscore(bord.getLevelCode(), bord.getSpeelModus(), bord.getSpelVariant());
        highscoreTeller.setText(score + "");
        if (score == 0){
            verwijderHighscoreKnop.setVisible(false);
            if (bord.getLevelCode() <= 0) highscoreTeller.setText("");
        } else {
            verwijderHighscoreKnop.setVisible(true);    
        }
    }
    
    /**
     * Update de score van de gebruiker. 
     * De gegevens hiervoor komen uit Bord.
     */
    public void updateBezetteEindvakken(){
        int totaal = bord.getAantalEindvakken();
        int bezet = bord.checkBezetteEindvakken();
        this.scoreTeller.setText(bezet + " / " + totaal);
    }
   
    /**
     * Toon de knop om het volgende level te starten
     */
    public void showVolgendeLevelKnop(){
        this.volgendeLevelKnop.setVisible(true);
        timer.start();
    }
    
    @Override
    public void actionPerformed(ActionEvent e) {
        Color kleur1 = Color.decode("0xA2FC7E"); //licht groen
        Color kleur2 = Color.LIGHT_GRAY;
        toggleKleurKnop(volgendeLevelKnop, kleur1, kleur2);
    }
    
    private void toggleKleurKnop(javax.swing.JButton knop, Color kleur1, Color kleur2){
        
        if (knop.getBackground().getRGB() == kleur1.getRGB()){
            knop.setBackground(kleur2);
        } else {
            knop.setBackground(kleur1);
        }
    }

    
    
    
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /*
         * Set the Nimbus look and feel
         */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /*
         * If Nimbus (introduced in Java SE 6) is not available, stay with the
         * default look and feel. For details see
         * http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(Sokoban.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(Sokoban.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(Sokoban.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(Sokoban.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /*
         * Create and display the form
         */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                if (SQLiteConnector.openConnection()) {
                    System.out.println("SQLite DB geopend.");
                    new Sokoban().setVisible(true);
                } else {
                    JOptionPane.showMessageDialog(null, "Fout bij het openen van de DB. Programma wordt afgesloten...");
                    System.out.println("Fout bij het openen van de SQLite DB. Programma wordt afgesloten...");
                }
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel CreditsLabel;
    private javax.swing.JPanel bordPanel;
    private javax.swing.ButtonGroup buttonGroup5;
    private javax.swing.JButton herstartLevelKnop;
    private javax.swing.JLabel highscoreLabel;
    private javax.swing.JLabel highscoreTeller;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JButton kiesLevelKnop;
    private javax.swing.JToggleButton kindmodusKnop;
    private javax.swing.JLabel levelLabel;
    private javax.swing.JLabel levelTeller;
    private javax.swing.JPanel menuPanel;
    private javax.swing.JLabel scoreLabel;
    private javax.swing.JLabel scoreTeller;
    private javax.swing.JLabel stappenLabel;
    private javax.swing.JLabel stappenTeller;
    private javax.swing.JButton startSpelKnop;
    private javax.swing.JToggleButton uitgebreideVariantKnop;
    private javax.swing.JButton verwijderHighscoreKnop;
    private javax.swing.JButton volgendeLevelKnop;
    // End of variables declaration//GEN-END:variables

}

